/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tugasbesarjeni1.form.model;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import tugasbesarjeni1.Database.VCD.penGembalian;

/**
 *
 * @author Indy
 */
public class PengembalianModel extends AbstractTableModel{
    private List<penGembalian> list = new ArrayList<penGembalian>();

    public void add(penGembalian pengembalian){
        list.add(pengembalian);
        fireTableRowsInserted(getColumnCount()-1, getRowCount()-1);
    }

    public void hapusTabel(int i, int row) {
        list.remove(i);
        fireTableRowsDeleted(i, row);
    }

    public int getRowCount() {
        return list.size();
    }

    public int getColumnCount() {
        return 6;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex){
            case 0 : return list.get(rowIndex).getNoID();
            case 1 : return list.get(rowIndex).getNama();
            case 2 : return list.get(rowIndex).getKode();
            case 3 : return list.get(rowIndex).getJudul();
            case 4 : return list.get(rowIndex).getTglPinjam();
            case 5 : return list.get(rowIndex).getTglKembali();
            default: return null;
        }
    }
    public String getColumnName(int column) {
        switch(column){
            case 0 : return "NO. ID";
            case 1 : return "NAMA";
            case 2 : return "KODE CD";
            case 3 : return "JUDUL";
            case 4 : return "TGL. PINJAM";
            case 5 : return "TGL. KEMBALI";
            default: return null;
        }
    }
}
